﻿@model Forum.Web.Models.LoginModel
@{
    ViewBag.Title = "ENode论坛-用户登录";
    Layout = "/Views/Shared/_SimpleLayout.cshtml";
}

<div class="middle-box text-center loginscreen  animated fadeInDown">
    <div>
        <div>
            <h1 class="logo-name">ENODE</h1>
        </div>
        <h3>用户登录</h3>
        @using (Html.BeginForm("Login", "Account", FormMethod.Post, new
        {
            @class = "m-t",
            @id = "form"
        }))
        {
            @Html.AntiForgeryToken()
            <div class="form-group">
                @Html.TextBoxFor(model => model.AccountName, new
                {
                    @class = "form-control",
                    @placeholder = "用户名",
                    @required = "",
                    @data_msg_required = "<i class='fa fa-times-circle'></i> 请输入用户名"
                })
            </div>
            <div class="form-group">
                @Html.PasswordFor(model => model.Password, new
                {
                    @class = "form-control",
                    @placeholder = "密码",
                    @required = "",
                    @data_msg_required = "<i class='fa fa-times-circle'></i> 请输入密码"
                })
            </div>
            <button type="button" class="btn btn-primary block full-width m-b" onclick="submitForm()">
                登 录
            </button>
            <p class="text-muted text-center">
                <a href="/"><small>返回首页</small></a>
                |
                @Html.ActionLink("注册一个新账号", "Register", "Account")
            </p>
        }
    </div>
</div>

@section Script{
    <script>
        function submitForm() {
            com.submitForm({
                isValid: true,
                $form: $("#form"),
                headers: { "RequestVerificationToken": $("input[name='__RequestVerificationToken']").val() },
                success: function (result) {
                    if (result.success) {
                        var returnUrl = '@ViewBag.ReturnUrl';
                        if (com.isStringEmpty(returnUrl)) {
                            location.href = '/home/index';
                        }
                        else {
                            location.href = returnUrl;
                        }
                    } else {
                        toastr.error(result.errorMsg);
                    }
                }
            });
        }
    </script>

}